import operate from '@dfeidao/atom-nodejs/db/operate';
import log from '@dfeidao/atom-nodejs/logger/log';
import doc_code from '@dfeidao/atom-nodejs/msg/doc-code';
import { systemid } from '../../atom/config';

interface Message {
	filter: {
		hidden_name: string[];

		risk_po_type_no: string;
		risk_po_name: string;
	}
}

export default async function atom(msg: Message, action_id: string, session_id: string) {
	log('Service begin');
	// todo

	const { insert, exec } = operate(action_id, session_id, systemid);

	const { result } = await doc_code(action_id, session_id, systemid, 'BM0014343', '', 1);

	// insert('risk_point_name', { risk_po_name_no: result, risk_po_name: msg.filter.risk_po_name, risk_po_type_no: msg.filter.risk_po_type_no });

	msg.filter.hidden_name.forEach((v, idx) => {
		const name = msg.filter.hidden_name[idx][0];
		const no = msg.filter.hidden_name[idx][1];
		insert('asso_hidden_sou', { risk_po_name_no: result, hidden_source: no, hidden_name: name });
	})


	const res = await exec();
	log('Service end');
	return res;
}
